package savet.util;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Adisson Marinho
 */
public class SauditaLog {

    public static final String SAUDITA_LOG = "saudita_log";
    private static Logger logger;
    private static Handler handler;

    static {
        logger = Logger.getLogger(SAUDITA_LOG);
        System.out.println("logger " + logger);
    }

    public SauditaLog() {
        try {
            handler = new FileHandler(SAUDITA_LOG, true);
//            logger.addHandler(handler);
        } catch (IOException ex) {
            Logger.getLogger(SauditaLog.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SecurityException ex) {
            Logger.getLogger(SauditaLog.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static void adicionarInfoLog(Class clazz, String log) {
        logger.logp(Level.INFO, clazz.getName(), "", log);
    }

    public static void adicionarInfoLog(String log) {
        adicionarInfoLog(SauditaLog.class, log);
    }

    public static void adicionarWarningLog(Class clazz, String log) {
        logger.logp(Level.WARNING, clazz.getName(), "", log);
    }

    public static void adicionarWarningLog(String log) {
        logger.warning(log);
    }

    public static void adicionarSevereLog(Class clazz, String log) {
        logger.logp(Level.SEVERE, clazz.getName(), "", log);
    }
    public static void adicionarSevereLog(String log) {
        adicionarSevereLog(SauditaLog.class, log);
    }

    public static void adicionarSevereLog(Class clazz, String msg, Throwable ex) {
        logger.logp(Level.SEVERE, clazz.getName(), "", msg, ex);
    }

    public static void adicionarSevereLog(String msg, Throwable ex) {
        logger.log(Level.SEVERE, msg, ex);
    }

    public static Logger getLogger() {
        return logger;
    }
}
